package com.herench.bs.handler;

import com.herench.bs.agent.IPersonAgent;
import com.herench.bs.annotation.Handler;
import com.herench.bs.support.AbstractMessageHandler;
import com.herench.bs.support.RequestMessage;
import com.herench.bs.support.ResponseMessage;
import org.springframework.stereotype.Component;
import org.springframework.util.Assert;

import java.util.Map;

/**
 * cleverClinic
 * com.herench.bs.handler
 *
 * @author wangwenkai
 * @date 2018/1/10/13:36
 * 检查手机号状态
 */
@Component
@Handler(code = "100238" ,name="检查手机号状态")
public class CheckPhoneStatusHandler extends AbstractMessageHandler {
    @Override
    protected ResponseMessage innerHandler(RequestMessage requestMessage) throws Exception {
        ResponseMessage responseMessage = new ResponseMessage(requestMessage.getId());
        String channelCode = requestMessage.getArgsPropertyStringValue("sysCode");
        Assert.notNull(channelCode, "sysCode 不能为空！");
        String phone = requestMessage.getArgsPropertyStringValue("phone");
        Assert.notNull(phone, "phone 不能为空！");
        IPersonAgent personAgent = getCleverClinicContext().getApplicationContext().getBean(IPersonAgent.class);
        Map<String, Object> resMap = personAgent.checkPhoneStatus(channelCode, phone);
        responseMessage.setData(resMap);
        getPropertiesFromInvokerResultMap(responseMessage, resMap);
        return responseMessage;
    }
}
